<template>
  <el-table
    :data="tableData"
    style="width: 100%"
    :row-class-name="tableRowClassName">
    <el-table-column
    align='center'
      prop="id"
      label="用户id"
      width="400">
    </el-table-column>
    <el-table-column
    align='center'
      prop="name"
      label="姓名"
      width="180">
    </el-table-column>
    <el-table-column
    align='center'
      prop="password"
      label="用户密码">
    </el-table-column>
    <el-table-column
    align='center'
      prop=status
      label="用户类型"
      >
      <template slot-scope="scope">
        <div v-if="scope.row.status==true">普通用户</div>
        <div v-if="scope.row.status!=true">管理员</div>
      </template>
    </el-table-column>
  </el-table>
</template>

<style>
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>

<script>
import axios from 'axios'
  export default {
    methods: {
      tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
      }
    },
    data() {
      return {
        tableData: []
      }
    },
    created(){
      axios.get(`http://localhost:8088/allUser`).then(response=>{
        console.log(response.data)
        this.$set(this,'tableData',response.data)
        console.log(this.tableData)
      })
    },
  }
</script>

<style>

</style>